var datainfo = [
	"羊辞旧岁山佩玉，猴接新年日流金",
	"猴捧仙桃国安人寿，羊衔嘉穗物阜年丰。",
	"祝大家猴年行好运，万事遂心愿",
	"愿你抱着平安，拥着健康，拽着吉祥",
	"寻梦梦就圆，日子千般万种甜",
	"金猴献礼，家家顺利",
	"祝大家工作舒心，朋友知心，爱人同心，事事称心！",
	"祝大家新的一年：健康快乐像马猴",
	"愿快乐跟随你，祝家人春节愉快",
	"金猴报春归，春归金猴报",
	"祝您猴年好运挡不住，财源滚滚来",
	"祝您新年：手头有钞票，梦里都在笑",
	"祝2016想财财就来，金山银海好运在",
	"祝你猴年挣得猴多猴多的，心情猴好猴好的",
	"祝你猴年前程一个筋斗十万八千里",
	"愿你新年机灵诡秘如猕猴，健康快乐像马猴",
	"想财财就来，金山银山在 ",
	"祝您乐驰千里猴，更上一层楼",
	"请你打开窗，让我新春的祝愿，飘进你的心坎。",
	"新年新旅程，祝你一路顺风。",
	"愿快乐跟随你，祝家人春节愉快",
	"祝大家福星高照，合家团圆。",
	"祝您新年家庭和睦，生活幸福",
	"猴年事业直登高，金银财宝装满包",
	"愿您幸福像烟花绽放，心情像汤圆蜜甜",
	"新年快乐最好，微信红包不少",
	"祝大家猴年荷包满满，活力满满！",
	"新年到，问个好",
	"春节了：要身体好、心情好、假期要过好。",
	"看过了许多美景，都不如你",
	"到此一游，祝大家：猴年快乐！",
	"呐，人呢，最重要的就是嗨森嘛",
	"春节你好，猴年你好，大家好才是真的好",
	"猴猴嗨森！",
	"许个愿真的能实现嘛",
	"吃吃喝喝过新年",
	"新年新气象，新年快乐",
	"猴年发发发，大家一起旺旺旺",
	"愿新的一年里，快乐跟随你我他",
	"祝大家春节愉快",
	"希望2015许下的愿望，2016都能实现",
	"你问我一声，你敢答应吗",
	"猴赛雷！恭喜发财，红包拿来！",
	"猴年要什么？要大家身体健康，心想事成！",
	"大师兄，师傅被妖怪抓走了",
	"新年我只要你快乐?",
	"和你的故事，想在猴年里继续书写",
	"弹幕什么的，最好玩了。俺来过，留个痕",
	"路过，爱过",
	"大王叫我来巡山",
	"猴年种下一颗梦想，来年长成猴王…",
	"这是什么？可以吃的吗？",
	"2016，平安健康就好！",
	"愿你365天天天开心，时时快乐 ，秒秒幸福！",
	"祝福走点心，请用红包说话",
	"真爱就是知道对方长的跟猴似的还不离不弃",
	"金猴迎新年，财到福气到",
	"祝您新年快乐，年年有余！年年有今朝，岁岁平安！",
	"猴年春节到，猴福乐逍遥",
	"新年重环保，健康牢，平安快乐最重要",
	"祝猴年大吉，合家团圆",
	"祝大家在新的一年步步高升，薪资涨不停",
	"快乐欢畅、幸福守候，温馨不断、红红火火",
	"新年开启，祝福升级，猴年精彩继续！",
	"祝朋友们待人一心一意，爱情一劳永逸",
	"有一种祝福，淡淡几句，收到了就能泛起笑意",
	"猴年大吉，幸福安康",
	"祝猴年郎有财女有貌",
	"事事顺心，事业有成，给大家拜年咯！",
	"恭喜发财过年好，红包满满乐开怀",
	"让云捎去满心的祝福，点缀你甜蜜的梦",
	"新年里，记得对身边人多一点迁就，少一点烦躁",
	"放下过去不越快，迎接猴年新气象",
	"旧事烦心去，辉煌看今朝",
	"愿你家兴业兴财源兴，人旺体旺精神旺",
	"幸福一年一年长，青春常驻你身上",
	"猴儿年猴气象",
	"过年大家都干什么呢",
	"电量满格过猴年",
	"感觉自己萌萌哒",
	"祝大家越活越年轻！像猴儿一样活蹦乱跳",
	"你好我好大家好",
	"猴年到，祝福到，就差红包没有到",
	"希望家人父母越活越年轻",
	"啊哈哈新年终于有新衣服穿了，好嗨森",
	"手动点赞",
	"猴年吉祥！祝福一切如你所愿！",
	"你们这么调皮家人造吗",
	"过年了，送你个攒窜天猴",
	"巴拉巴拉送祝福，大家新春快乐！",
	"回家回家",
	"把手给我举！起！来！",
	"祝亲爱的们，新年快乐！",
	"新年要新鲜",
	"对！就是你！你已经被我的祝福包围了！",
	"这个背景音乐也是够喜庆",
	"哈哈哈，楼上的弹幕好搞笑",
	"2016，猴健康",
	"猴赛雷是猴嗨森的欧巴",
	"日子好快啊",
	"许个愿望，希望新年梦想成真！",
	"没有矫情的祝福给你，只愿你天天开心每一天！",
	"祝大家新的一年，发发发大财",
	"祝愿家人身体健康，有机会多出去旅游玩玩",
	"哈哈哈哈哈",
	"新的一年，希望自己过的充实一点，一起加油。",
	"简简单单，快快乐乐",
	"猴年！我准备好迎接你了嘻嘻",
	"我是中国人，有颗中国心。祝福祖国繁荣富强！",
	"猴年希望自己知足常乐，笑口常开",
	"愿猴年有情人终成眷属！",
	"今年肯定会去年好！恩！",
	"祝无法与家人团圆的兄弟姐妹们猴年快乐",
	"祝大家身体倍儿棒，心情倍儿好",
	"过年孩子收的红包钱还赶不上年终奖！",
	"猴年行大运，我行，你更行",
	"猴年发财，不管你信不信，反正我信",
	"女神！新年我会一直撒浪嘿油！",
	"本宝宝祝大家猴年颜值通通爆表！",
	"我要表白！爱你么么么哒",
	"祝大家身体倍儿棒，心情倍儿好",
	"过年孩子收的红包钱还赶不上年终奖！",
	"猴年行大运，我行，你更行",
	"猴年发财，不管你信不信，反正我信",
	"猴年，姐主要看气质",
	"本宝宝祝大家猴年颜值爆表",
	"友谊万岁，理解万岁！",
	"希望猴年自己可以变成网红哈哈",
	"你们城里人真会玩",
	"猴赛雷这波，我服！新年快乐！",
	"猴年，姐主要看气质",
	"祝你新年快乐，喜气洋洋",
	"快乐是自己给的，祝大家猴年笑口常开！"
];

var flag = false;
var timer1 = "";

function getReandomColor() {
	return '#' + (function(h) {
		return new Array(7 - h.length).join("0") + h
	})((Math.random() * 0x1000000 << 0).toString(16))
}
//在0到num内随机取一个整数
function getTh(num) {
	return parseInt((Math.random() * num << 0).toString(10));
}
//往弹幕中添加内容
function send_reply2(num, data, amount) {
	var html = "";
	var _height = $(window).height() - 340;
	var _left = $(window).width() - $(this).width() + 220;
	for (var i = 0; i < num; i++) {
		var info = data[getTh(amount)];
		var _top = getTh(_height) + 120;
		var width = info.length;
		html += "<div class='textbox' style='left:120%;top:" + _top + "px;'><p style='width:" + width + "em;'>" + info + "</p><div class='trigon'></div></div>";
	}
	$("body #content").append(html);
	init_screen();
}

function send_replyMy(info) {
	var _left = getTh($(window).width());
	var _top = 260;
	var width = info.length;
	if (width) {
		var zindex = 100;
	};
	var div = "<div class='textbox' style='left:60%;top:260px;'><p style='background:#cc1c25;color:#fff;width:" + width + "em;z-index:" + zindex + ";'>" + info + "</p><div class='trigon2'></div></div>";
	$("body #content").append(div);
	init_screen();

}
//动画开启
function beginAnimate() {
	$("#array").hide();
	init_screen();
	if (flag == false) {
		timer1 = setInterval("send_reply2(5,datainfo,133)", 10000);
	    flag = true;
	} 
}
//动画停止
function stopAnimate() {
	clearInterval(timer1);
	var html = $("#content").html();
	$("#content").html("");
	$("#content").append(html);
	$("#content div").stop();
	flag = false;
}
//获取输入框中信息
function getInputInfo() {
	var content = $("#inputtext").val();
	if ($.trim(content) == "") {
		//		alert("亲，请输入你的想说的话！");
		return false;
	};
	return content;
}

//让弹幕中内容动起来
function init_screen() {
	$("#content").find(".textbox").show().each(function() {
		if (parseInt($(this).css("left")) < -100) {
			//$(this).remove();
		}
		var time = 28000;
		if ($(this).index() % 2 == 0) {
			time = 26000;
		}
		if ($(this).index() % 3 == 0) {
			time = 24000;
		}
		if ($(this).index() % 4 == 0) {
			time = 22000;
		}
		if ($(this).index() % 5 == 0) {
			time = 20000;
		}
		if ($(this).index() % 7 == 0) {
			time = 18000;
		}
		if ($(this).index() % 8 == 0) {
			time = 22000;
		}
		$(this).animate({
			left: "-" + $(this).width() + "px"
		}, time, function() {
			$(this).remove();
		});
	});
}
$("#showinput").on("click", function() {
	stopAnimate();
	$("#inputtext").val("");
	$("#inputbox").show();
});
$("#zxyh").on("click", function() {
	init_screen();
	beginAnimate();
	$("#inputbox").hide();
});
$("#xhl").on("click", function() {
	var info = getInputInfo();
	if (info == "") {
		return false
	} else {
		send_replyMy(getInputInfo());
		beginAnimate();
		$("#inputbox").hide();
	}

});
$("#stopAnimate").on("click", function() {
	stopAnimate();
});
$("#beginAnimate").on("click", function() {
	beginAnimate();
});
$(".inputtext").attr("maxlength", "24");

/*页面加载完成之后*/
window.onload = function() {
	//	$("#loading").hide();
	//	$(".Start").css("opacity","1");
	//	$(".Start").css("display", "none");
	//	$(".bodyBlock").css("opacity", "1");
	//	$("body").css("background", "#000");

	bodyHeight = $(window).height();
	$(".bodyBlock").height(bodyHeight);
	$(".bodyBlock,.swiper-container,.swiper-slide").height(bodyHeight);

	var slideWidth = $(".bodyBlock").width();
	var slideHeight = $(".bodyBlock").height();
	scaleW = slideWidth / 320;
	scaleH = slideHeight / 480;
	var resizes = document.querySelectorAll('.resize');
	for (var j = 0; j < resizes.length; j++) {
		resizes[j].style.width = parseInt(resizes[j].style.width) * scaleW + 'px';
		resizes[j].style.height = parseInt(resizes[j].style.height) * scaleH + 'px';
		resizes[j].style.top = parseInt(resizes[j].style.top) * scaleH + 'px';
		resizes[j].style.left = parseInt(resizes[j].style.left) * scaleW + 'px';
		//confirm(j);
	};
	//resize 功能，在标签加上resize类名之后就以320*480为标准的屏幕上进行定位。

	var mySwiper = new Swiper('.swiper-container', {

		speed: 500,
		direction: "vertical",
		touchRatio: 2,
		//		pagination: ".swiper-pagination",
		mousewheelControl: !0,
		onInit: function(a) {
			a.myactive = 0;
			for (var b = 0; b < a.slides.length; b++) a.slides[b].style.zIndex = 0;
			a.slides[a.myactive].style.zIndex = 1, swiperAnimateCache(a), swiperAnimate(a)
		},
		onTransitionStart: function(a) {
			a.params.onlyExternal = !0
		},
		onTransitionEnd: function(a) {
			a.params.onlyExternal = !1, a.myactive = a.activeIndex;
			for (var b = 0; b < a.slides.length; b++) a.slides[b].style.zIndex = 0;
			a.slides[a.myactive].style.zIndex = 1, swiperAnimate(a)
		},
		watchSlidesProgress: !0,
		onProgress: function(a) {
			var b, c, d, e;
			for (a.myactive || (a.myactive = 0), b = 0; b < a.slides.length; b++) c = a.slides[b], es = c.style, d = c.progress, e = d * a.height, opacity = 0, b == a.myactive && (opacity = 1 - Math.abs(d) / 2), (a.slides[a.myactive].progress > 0 && b == a.myactive + 1 || a.slides[a.myactive].progress < 0 && b == a.myactive - 1) && (opacity = .5 + Math.abs(.5 * a.slides[a.myactive].progress)), c.style.opacity = opacity, b != a.myactive && (es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = "translate3d(0," + e + "px,0)")
		},
		onSetTransition: function(a, b) {
			for (var c = 0; c < a.slides.length; c++) es = a.slides[c].style, es.webkitTransitionDuration = es.MsTransitionDuration = es.msTransitionDuration = es.MozTransitionDuration = es.OTransitionDuration = es.transitionDuration = b + "ms"
		},


		onSlideChangeStart: function(swiper) {
//			console.log(mySwiper.activeIndex);
			swiperAnimate(swiper);
			if (mySwiper.activeIndex == 1) {
				stopAnimate();
				$("#inputbox").hide();
				$("#content").html("");
			}else if (mySwiper.activeIndex == 0) {
				$("#array2").show();
				$("#array").hide();
			} else if (mySwiper.activeIndex == 2) {
				send_reply2(5,datainfo,133);
				beginAnimate();
				$("#array").hide();
				$("#array2").hide();
			} else {
				return false;
			}
		},
		onSlideChangeEnd: function(swiper) {
//			console.log(mySwiper.activeIndex);
			swiperAnimate(swiper);
			if (mySwiper.activeIndex == 1) {
				$("#array2").hide();
				$("#array").show();
			}
		}

	});
	//初始化音乐
	var a = document.getElementById('bgMusicActionStop');
	var audio = globalCreateAudioPlayer();
	audio.init(a, true);
	$("#bgMusicBlock").click(function() {
		var played = audio.playOrPause();
		if (played) {
			$(".bgMusic").find("img").attr("src", "images/bgMusic.png");
			$(".bgMusic").find("img").addClass("bgMusic-img");
			$(".music-bg").show();
		} else {
			$(".bgMusic").find("img").attr("src", "images/bgMusic_close.png");
			$(".bgMusic").find("img").removeClass("bgMusic-img");
			$(".music-bg").hide();
		}
	});
	$("#bgMusicActionStop").attr("src", "other/music2.mp3?v=" + new Date().getTime());
	
}
$.ajaxSetup({
	cache: false //设置成false将不会从浏览器缓存读取信息
});